<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>IQL数据平台 - 修改密码</title>
    <link rel="shortcut icon" href="/images/mc.png">
    <link href="/hplus/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="/hplus/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="/hplus/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/hplus/css/animate.min.css" rel="stylesheet">
    <link href="/hplus/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="/bootstrap-table/dist/bootstrap-table.min.css" rel="stylesheet">
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>

    <style>
        .middle-box {
            padding-top: 100px;
        }
    </style>
</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen   animated fadeInDown">
        <div>
            <div>

                <h1 class="logo-name">IQL</h1>

            </div>
            <h3>欢迎使用 IQL数据平台</h3>
            <h4 class="text-warning">第一次登录系统需要修改密码才能继续使用<br>（初始密码由管理员提供）。</h4>
            <form id="changepw" class="m-t" method="post" role="form" onsubmit="return check()" action="/changepw">
                <input id="username" name="username" type="hidden" th:value="${username}">
                <div class="form-group" id="password-input">
                    <input type="password" id="password" name="password" class="form-control" placeholder="请输入原密码" required="">
                    <span id="password-error" class="help-block m-b-none"></span>
                </div>
                <div class="form-group" id="npassword-input">
                    <input type="password" id="npassword" name="npassword" class="form-control" placeholder="请输入新密码" required="">
                    <span id="npassword-error" class="help-block m-b-none"></span>
                </div>
                <div class="form-group" id="cpassword-input">
                    <input type="password" id="cpassword" name="cpassword" class="form-control" placeholder="请再次输入密码" required="">
                    <span id="cpassword-error" class="help-block m-b-none"></span>
                </div>

                <div>
                    <label class="form-label text-warning"></label>
                </div>

                <button type="submit" class="btn btn-primary block full-width m-b">提 交</button>

            </form>
        </div>
    </div>
    <script src="/hplus/js/jquery.min.js?v=2.1.4"></script>
    <script src="/hplus/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="/hplus/js/plugins/iCheck/icheck.min.js"></script>
    <script>

    </script>

<script>

    $(function () {
        validate = function(flag,colume,info){
            if(flag){
                $("#"+colume+"-input").addClass("has-error")
                $("#"+colume+"-error").html('<i class="fa fa-times-circle">'+info)
                return false
            }else{
                $("#"+colume+"-input").removeClass("has-error")
                $("#"+colume+"-error").html("")
                return true
            }
        }


        check=function(){
            var username = $("#username").val();
            var password = $("#password").val();
            var npassword = $("#npassword").val();
            var cpassword = $("#cpassword").val();
            var vpassword = false,
                vnnpassword = false;
            $.ajax({
                url: '/mcdata/user/system/checkusernameandpw',
                type: 'POST',
                async: false,
                data: {'username': username,'password':password},
                success: function( response ) {
                    vpassword = validate(!response,"password","原密码错误")
                },
                error: function( error ) {
                    //layer.msg('添加失败：'+error.status, {icon: 2});
                }
            });
            var vnpassword = validate(npassword.trim().length<6,"npassword","长度必须大于等于6位")
            if(vpassword){
                vnnpassword = validate(password.trim()==npassword.trim(),"npassword","新密码不能和原密码一样")
            }
            var vcpassword = validate(cpassword.trim()!=npassword.trim(),"cpassword","两次输入的密码不一样")

            if(!(vnpassword&&vcpassword&&vpassword&&vnnpassword)){
                console.log("检验不通过")
                return false
            }
            return true
        }

    })
</script>
</body>

</html>
